import { defineStore } from "pinia";
import { computed } from "vue";
import { getUserId, getUserName, getUserRole } from "@/auth";

export const useGlobalStore = defineStore("global", () => {
  // 使用 computed 让数据动态更新
  const userName = computed(() => getUserName());
  const userRole = computed(() => getUserRole());
  const userId = computed(() => getUserId());

  return {
    userName,
    userRole,
    userId
  };
});
